package org.example.factory.simple_factory;

/**
 * @Author KEKE
 * @Date 2024/7/1 9:51
 * @Description 简单咖啡工厂类，用来生成coffee
 * @Version 1.0
 */
public class SimpleCoffeeFactory {
    public Coffee createCffee(String type) {

        //声明coffee类型的变量，根据不同类型创建不同的coffee子类对象
        Coffee coffee = null;
        if ("american".equals(type)) {
            coffee = new AmericanCoffee();
        } else if ("latter".equals(type)) {
            coffee = new LatterCoffee();
        } else {
            throw new RuntimeException("所点的咖啡没有此类型");
        }
        return coffee;
    }
}
